from flask_wtf.file import FileField, FileAllowed, FileSize
from wtforms import StringField, IntegerField
from wtforms.validators import InputRequired

from apps.front.forms import BaseForm


class UploadImageForm(BaseForm):
    image = FileField(validators=[FileAllowed(['jpg', 'png', 'jpeg'], message="请上传图片文件!"),
                                  FileSize(max_size=5 * 1024 * 1024, message="图片大小不能超过5M!")])


class AddBannerForm(BaseForm):
    name = StringField(validators=[InputRequired(message='请输入轮播图名称！')])
    image_url = StringField(validators=[InputRequired(message='请输入轮播图图片链接！')])
    link_url = StringField(validators=[InputRequired(message='请输入轮播图跳转链接！')])
    priority = IntegerField(validators=[InputRequired(message='请输入轮播图优先级！')])


# 编辑
class EditBannerForm(AddBannerForm):
    id = IntegerField(validators=[InputRequired(message='请输入轮播图id！')])
